//
// security_helper.h
// libprotea
// Tools Library for the Protea Project / User and Group security helper functions
// Copyright (C) 2003, 2004, 2005 eXegeSys, Inc.
// Copyright (C) 2008 Bruce A. James
//
// This program is part of the Protea Project.
//
// The Protea Project is free software; you can redistribute it and/or modify it 
// under the terms of the GNU General Public License as published by the 
// Free Software Foundation, either version 3 of the License, or (at your 
// option) any later version.
//
// The Protea Project is distributed in the hope that it will be useful, but 
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
// for more details.
// 
// You should have received a copy of the GNU General Public License along 
// with this program.  If not, see <http://www.gnu.org/licenses/>.
// 
// Please send correspondence to:
// 
// theproteaproject@gmail.com
//

#ifndef __PROTEA_SECURITY_HELPER_H__
#define __PROTEA_SECURITY_HELPER_H__


enum security_update_mode {
	SECURITY_ADD_USER = 1,
	SECURITY_DEL_USER = 2,
	SECURITY_CHG_USER = 3,
	SECURITY_ADD_GROUP = 4,
	SECURITY_DEL_GROUP = 5,
	SECURITY_ADD_USER_TO_GROUP = 6,
	SECURITY_DEL_USER_FROM_GROUP = 7
};

struct security_update_message
{
	security_update_mode mode;
	int user_name_len;
	int user_pass_len;
	int group_name_len;
	int descr_len;
	char data[1];
};


class __EXPORT security_info_manager {
public:
	security_info_manager();

	void SubmitChange( security_update_mode mode, XCAppInterface* app );
	void FromMessageType( security_update_message* input );

	char* user_name;
	char* user_password;
	char* group_name;
	char* description;

private:
	void FillSecurityVariable( char*& result, int len, char*& offset );
	void FillMessageVariable( char* result, int len, char*& offset );
};

#endif
